package com.ftg.learn.chapter09.reflech.demo02.service;

/**
 * 这是一个类，表示其它类信息，
 * 用来用为模板
 * @author kangjx
 * @date 2023/1/13
 */
public class MyClassInfo {

    /**
     * 其它类的名称
     */
    private String name;

    /**
     * 完成类地址
     * com.ftg.learn.chapter09.reflech.demo02.entity.Cat
     */
    private String path;

    /**
     * 关联对象实例
     */
    private Class myself;

    public MyClassInfo(String path){
        this.path = path;
        if(path != null && !path.equals("")){
            this.name = path.substring(path.lastIndexOf(".") + 1);
        }
        try {
            this.myself = Class.forName(path);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }


    public MyClassInfo(Class c){
        this.name = c.getSimpleName();
        this.path = c.getName();
        this.myself = c;
    }


    public String getName() {
        return name;
    }

    public String getPath() {
        return path;
    }

    public Class getMyself() {
        return myself;
    }
}
